import os
import random

import yaml


class YamlUtil:
    def read_yaml_func(self, yaml_name):
        with open(os.getcwd() + "/" + yaml_name, mode="r", encoding="utf-8") as f:
            value = yaml.load(stream=f, Loader=yaml.FullLoader)
            return value
    def read_yaml_key(self,key):
        with open(os.getcwd() + "/Pat_ID.yml", mode="r", encoding="utf-8") as f:
            value = yaml.load(stream=f, Loader=yaml.FullLoader)
            return value[key]

    def write_yaml_func(self, yaml_name,date):
        with open(os.getcwd() + "/" + yaml_name, mode="a", encoding="utf-8") as f:
            yaml.dump(data=date, stream=f, allow_unicode=True)

    def clear_yaml_func(self):
        with open(os.getcwd() + "/Pat_ID.yml", mode="w", encoding="utf-8") as f:
            f.truncate()

    def get_random(self, min1, max1):
        print("111")
        result = random.randint(int(min1), int(max1))
        return str(result)

